<{extend name="public/base"}>
<{block name="foot_source"}>
<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
<link rel="stylesheet" type="text/css" href="/static/webuploader/webuploader.css">
<{/block}>
<{block name="content"}>
<!-- left column -->
<div class="col-md-12">
    <!-- general form elements -->
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title"><{$title}></h3>
        </div>
        <!-- /.box-header -->
        <!-- form start -->
        <form role="form" method="post" action="<{:url('admin/product/handle')}>" >
            <div class="box-body">
                <div class="form-group">
                    <label for="title">产品名称</label>
                    <input type="text" class="form-control" id="title" name="title" value="<{$model.title}>" placeholder="请输入产品名称">
                </div>
                <div class="form-group">
                    <label for="serial_number">产品编号</label>
                    <input type="text" class="form-control" id="serial_number" name="serial_number" value="<{$model.serial_number}>" placeholder="请输入产品编号">
                </div>
                <div class="form-group">
                    <label for="desc">产品描述</label>
                    <input type="text" class="form-control" id="desc" name="desc" value="<{$model.desc}>" placeholder="请输入产品描述">
                </div>

                <div id="uploader" class="wu-example">
                    <label for="cover">缩略图</label>
                    <!--用来存放文件信息-->
                    <div class="btns">
                        <input type="hidden" class="form-control" value="<{$model.cover}>" name="cover" id="cover" />
                        <img src="<{$model.cover}>" id="cover_show" />
                        <div id="picker">选择文件</div>
                    </div>
                </div>


                <!-- 目前工厂数量不多 就几家 所以不采用弹出页面的方式 -->
                <div class="form-group">
                    <label for="factory_id">所属工厂</label>
                    <select name="factory_id" id="factory_id" class="form-control">
                        <?php foreach($factory_list as $key => $item ){ ?>
                        <option value="<{$item.id}>" <{if condition="$model.factory_id eq $item.id"}>selected<{/if}> ><{$item.company_name}></option>
                        <?php } ?>
                    </select>
                </div>

                <div class="form-group">
                    <label for="market_price">市场价格</label>
                    <input type="text" class="form-control" id="market_price" name="market_price" value="<{$model.market_price}>" placeholder="请输入产品编号">
                </div>

                <div class="form-group">
                    <label for="sell_price">团购价格</label>
                    <input type="text" class="form-control" id="sell_price" name="sell_price" value="<{$model.sell_price}>" placeholder="请输入产品编号">
                </div>

                <div class="form-group">
                    <label for="salary">佣金</label>
                    <input type="text" class="form-control" id="salary" name="salary" value="<{$model.salary}>" placeholder="请输入产品编号">
                </div>

                <input type="hidden" value="<{$model.id}>" name="id" />

            </div>
            <!-- /.box-body -->

            <div class="box-footer">
                <button type="submit" class="btn btn-primary">提交</button>
                <a href="<?php echo url('admin/product/index'); ?>" class="btn btn-default">返回</a>
            </div>
        </form>
    </div>
    <!-- /.box -->
</div>


<{/block}>
<{block name="foot_script"}>
<script type="text/javascript">
    var BASE_URL = '/static/webuploader';
    var uploader = WebUploader.create({
        // swf文件路径
        swf: BASE_URL + '/js/Uploader.swf',
        // 文件接收服务端。
        server: '/admin/api/upload',
        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#picker',
        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false
    });

    // 当有文件被添加进队列的时候
    uploader.on( 'fileQueued', function( file ) {
        uploader.upload();
    });

    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    uploader.on( 'uploadSuccess', function( file,data ) {
        $("#cover").val(data.url);
        $("#cover_show").attr('src',data.url);
    });
</script>
<{/block}>

